﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class DirectoryCopy
{
    static void Main(string[] args)
    {
        string givenDirectory = @"C:\NetEssentials\Lectures\2.2. SQL Server";
        string newLocation = @"C:\NetEssentials";
        CopyDirectory(givenDirectory, newLocation);
    }

    static void CopyDirectory(string givenDirectory, string newLocation)
    {
        DirectoryInfo folderInfo = new DirectoryInfo(givenDirectory);
        string newFolderLocation = newLocation + "\\" + (new DirectoryInfo(givenDirectory)).Name;
        Directory.CreateDirectory(newFolderLocation);
        FileInfo[] files = folderInfo.GetFiles();
        foreach (FileInfo file in files)
        {
            File.Copy(file.FullName, newFolderLocation + "\\" + file.Name);
        }
        DirectoryInfo[] directories = folderInfo.GetDirectories();
        foreach (DirectoryInfo directory in directories)
        {
            CopyDirectory(directory.FullName, newFolderLocation);
        }
    }
}

